//
//  YXTeamView.m
//  跑跑快销
//
//  Created by 杨潇 on 14-4-28.
//  Copyright (c) 2014年 ylife. All rights reserved.
//

#import "YXTeamView.h"
#import "TNTeamCollectionViewCell.h"

@implementation YXTeamView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        _itemsViewHeight = 72;
        _tabbarHeight = 49;
        
    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/
- (void)createView
{
    //创建三个按钮的视图
    [self createItemsView];
    //创建团队列表视图
    [self createRelationshipView];

}


- (void)createItemsView
{
//    int itemsViewY;
//    if (ISDEVICE7) {
//        itemsViewY = 64;
//    }else{
//        itemsViewY = 44;
//    }
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, _itemsViewHeight)];
    view.backgroundColor = [UIColor lightGrayColor];
    [self addSubview:view];
    
    //通知
    _notificationButton = [[TNButton alloc]initWithFrame:CGRectMake(40, 8, 44, 64)];
    [_notificationButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
    [_notificationButton.titleLabel setFont:[UIFont systemFontOfSize:11]];
    [_notificationButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [_notificationButton setTitle:@"通知" forState:UIControlStateNormal];
    _notificationButton.imageView.layer.masksToBounds = YES;
    _notificationButton.imageView.layer.cornerRadius =5;
    [_notificationButton setImage:[UIImage imageNamed:@"a.png"] forState:UIControlStateNormal];
    [view addSubview:_notificationButton];

    //团队报表
    _teamStatementButton = [[TNButton alloc]initWithFrame:CGRectMake(138, 8, 44, 64)];
    [_teamStatementButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
    [_teamStatementButton.titleLabel setFont:[UIFont systemFontOfSize:11]];
    [_teamStatementButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [_teamStatementButton setTitle:@"团队报表" forState:UIControlStateNormal];
    _teamStatementButton.imageView.layer.masksToBounds = YES;
    _teamStatementButton.imageView.layer.cornerRadius =5;
    [_teamStatementButton setImage:[UIImage imageNamed:@"a.png"] forState:UIControlStateNormal];
    [view addSubview:_teamStatementButton];
    
    //聊天室
    _chatButton = [[TNButton alloc]initWithFrame:CGRectMake(236, 8, 44, 64)];
    [_chatButton.titleLabel setTextAlignment:NSTextAlignmentCenter];
    [_chatButton.titleLabel setFont:[UIFont systemFontOfSize:11]];
    [_chatButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    [_chatButton setTitle:@"聊天室" forState:UIControlStateNormal];
    _chatButton.imageView.layer.masksToBounds = YES;
    _chatButton.imageView.layer.cornerRadius =5;
    [_chatButton setImage:[UIImage imageNamed:@"a.png"] forState:UIControlStateNormal];
    [view addSubview:_chatButton];
}

- (void)createRelationshipView
{

    UIView *myView = [[UIView alloc]initWithFrame:CGRectMake(0,_itemsViewHeight, 320, 100)];
    myView.backgroundColor = [UIColor grayColor];
    _myButton = [TNButton addRoundButtonWithFrame:CGRectMake(130, 10, 60, 90)];
    [myView addSubview:_myButton];
    [self addSubview:myView];

    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    flowLayout.itemSize = CGSizeMake(100, 100);    //每个flow的尺寸就是在界面上现实的大小
    [flowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
    
    _collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0,_itemsViewHeight + 100, 320, PHONESIZEHEIGHT - _itemsViewHeight - 160 - _tabbarHeight) collectionViewLayout:flowLayout];
    [_collectionView setBackgroundColor:[UIColor darkGrayColor]];
    [_collectionView setScrollEnabled:YES];
    [_collectionView registerClass:[TNTeamCollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
    [self addSubview:_collectionView];
    
}



@end
